package com.ruoyi.report.controller;

import com.ruoyi.api.system.utils.poi.ExcelUtil;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.report.domain.ReportPosition;
import com.ruoyi.report.domain.ReportProfessional;
import com.ruoyi.report.service.IReportProfessionalService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("/report/professional")
public class ReportProfessionalController extends BaseController {

    private String prefix = "report/professional";

    @Autowired
    private IReportProfessionalService reportProfessionalService;

    /**
     * 职称晋升
     * @return
     */
    @GetMapping()
    public String professional()
    {
        return prefix + "/professional";
    }

    /**
     * 查询职称申报
     * @param reportProfessional
     * @return
     */
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ReportProfessional reportProfessional)
    {
        startPage();
        List<ReportProfessional> professionalList = reportProfessionalService.selectReportProfessionalList(reportProfessional);
        return getDataTable(professionalList);
    }

    /**
     * 导出职称申报任
     */
    @Log(title = "职称申报", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ReportProfessional reportProfessional)
    {
        List<ReportProfessional> list = reportProfessionalService.selectReportProfessionalList(reportProfessional);
        ExcelUtil<ReportProfessional> util = new ExcelUtil<ReportProfessional>(ReportProfessional.class);
        return util.exportExcel(list, "职称申报");
    }
}
